/*
 * File:   MundoSBS.h
 * Author: paula
 *
 * Created on 13 de octubre de 2014, 15:10
 */

#ifndef MUNDOSBS_H
#define MUNDOSBS_H

#include <iostream>
#include <vector>
#include <iostream>
#include <SDL2/SDL_ttf.h>
#include <thread>
#include <mutex>
#include <chrono>

#include "../Define/Structs.h"
#include "../Define/DefaultValues.h"

#include "Player.h"
#include "ClientSocket.h"
#include "Button.h"
#include "Label.h"
#include "ScreenManager.h"
#include "Character.h"
#include "Object.h"
#include "Enemy.h"
#include "Boss.h"
#include "SDL2/SDL_mixer.h"

#include <list>
#include "Circle.h"
using namespace std;

class MundoSBS {
public:
    MundoSBS();
    MundoSBS(const MundoSBS& orig);
    virtual ~MundoSBS();

    bool conectServer(ClientSocket* client, char *ip, int port);
    bool initButton(ClientSocket* client);
    bool goodByePlayer();
    bool initLevel(ClientSocket* client);
    bool initLevel2(ClientSocket* client);
    bool levelFinished(ClientSocket* client);
    
    bool waitForStart(ClientSocket* client);
    bool waitingPlayers(ClientSocket * client);
    bool waitingPlayersToReload();
    bool waitingForServer(ClientSocket* client);
    
    void createFigures(SDL_Renderer* renderer);
    void createFigures2(SDL_Renderer* renderer);
    bool loadLabels();

    void updateDynamicObjects(struct ObjectInit* object, SDL_Renderer* renderer);
    void updateDynamicObjects2(struct ObjectInit* object, SDL_Renderer* renderer);

    bool startGame(ClientSocket* client);


    bool end();

    int receiveLevelTwo(ClientSocket* client);
    int initWindowGame(ClientSocket* client, char *ip, int port, char name [8]);
    int recv(ClientSocket* client, void *buf, int len);
    void recvNextPlayer(ClientSocket* client);
    //solo elimino cosas de los contenedores antes de pasar de nivel.

    void garbageCollector();
    void setGameOver(bool flag);
    bool getGameOver();
    bool waitingForReload;
private:

    void checkQuitOrZoom(SDL_Event* event, bool* quit, bool* zoomIn, bool* zoomOut);

    bool endMain;
    bool reloadLevelOne;
    bool salioManualmente;

    Window* gWindow;
    Player* player;
    vector<Drawable*> dynamicObjects;
    vector<Drawable*> staticObjects;
    vector<Drawable*> dynamicObjects2;
    vector<Drawable*> staticObjects2;
    SBSLog* myLogFile;
    vector<struct ObjectInit> worldObjects;
    vector<struct ObjectInit> worldObjects2;
    struct Pantalla window;
    //shoot 
    vector<Drawable*> bulletList;

    //SDL_Renderer* gRenderer;
    vector<struct NewPlayer> allPlayers;
    bool gameOver;
    bool isObserver;

};

#endif  /* MUNDOSBS_H */

